<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class updateUservalidata extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    public function rules()
    {
        return [
            'username' => 'required|min:2|max:16',
            'sex'      => 'required',
            'member'   => 'required|max:3',
            'phone'    => ['required','regex:/^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/u'],
            'file'     => 'image',
        ];
    }

    public function messages()
    {
        return [
            'file.image'        => '图片不合法',
            'email.unique'      => '邮箱已被注册',
            'phone.unique'      => '手机号已被注册',
            'member.max'        => '会员等级最高为钻石会员',
            'member.required'   => '请选择正确的会员等级',
            'username.required' => '用户名不能为空',
            'email.email'       => '邮箱格式不正确',
            'username.min'      => '用户名不能小于2',
            'username.max'      => '用户名不能大于16',
            'sex'               => '请选择性别',
            'email.email'       => '邮箱格式不正确',
            'phone.regex'       => '手机号码不正确',
            'phone.required'    => '手机号不能为空',
        ];
    }
}
